<%- include('./templates/_headerDetail') %>
    <script type="text/javascript" src="/lib/moment/moment.js"></script>
    <script type="text/javascript" src="/lib/moment/zh-cn.js"></script>
    <div id="container" class="container">
        <div class="list-detail">
          <intput type="text" hidden data-val="<%= JSON.stringify(user) %>" id="user-news"></intput>
          <intput type="text" hidden data-val="<%= article._id %>" id="postId"></intput>
          <intput type="text" hidden data-val="<%= article.author._id %>" id="touserId"></intput>
          <div class="list user-list">
            <div class="list-item img-txt-list-item">
              <div class="pull-left img-item">
                <img src="<%= article.author.headimgurl %>">
              </div>
              <div class="pull-right txt-item">
                <p class="item-title">
                    <span><%= article.author.username %></span>
                    <!-- <a href="javaScript:;" class="cancel-focus">取消关注</a> -->
                    <a href="javaScript:;" class="focus focus-btn" data-id="<%= article.author._id %>">关注</a>
                </p>
                <div class="item-other">
                    <!-- <span class="address"><i class="iconfont">&#xe939;</i><%= article.author.province%>  <%= article.author.city%></span> -->
                    <span class="integral"><i class="iconfont">&#xe916;</i><b><%= article.author.integral%></b></span>
                    <span class="collection"><i class="iconfont">&#xe8e9;</i><b><%= article.collection_num%></b></span>
                    <span class="comments"><i class="iconfont">&#xe957;</i><b><%= article.comments.length %></b></span>
                    <span class="meta"><i class="iconfont">&#xe8e5;</i><b><%= article.meta_num%></b></span>
                </div>
              </div>
            </div>    
          </div> 

          <!-- 文章详情 -->
          <div class="detail-content">
            <p class="title" id="post-title"><%= article.title %></p>
            <p class="detail-other">
              <span>作者：<%= article.author.username %></span>
              <span>时间：<%= locals.moment(article.created_at,'YYYYMMDD').fromNow() %></span>
              <span>分类：<%= article.category.name%></span>
            </p>
            <% if (article.photo.length != 0) { %>
              <div class="swiper-container">
                  <div class="swiper-wrapper">
                        <% article.photo.forEach(function (photo, index){ %>
                          <div class="swiper-slide">
                              <img src="/upload/<%= photo.filename %>">
                          </div>
                        <% }) %>
                  </div>
              </div>
            <% } %>
            <div class="content">
              <p id="post-content"><%= article.body%></p>
            </div>
            <div class="contact-txt">
              <p><label>联系人：</label><%= article.contact_name %></p>
              <p><label>联系电话：</label><%= article.contact_phone %></p>
              <p><label>地点：</label><i class="iconfont">&#xe939;</i><%= article.area %></p>
            </div>
          </div>
  
          <!-- 文章评论 -->
          <div class="comments">
            <div class="weui-loadmore weui-loadmore-line">
                <span class="weui-loadmore-tips">文章评论</span>
                  <ul class="weui-comment">
                    <% if (article.comments.length > 0) {%>
                        <% article.comments.forEach(function (comment, index){ %>
                          <li class="weui-comment-item">
                              <div class="userinfo">
                                <strong class="nickname">
                                    <%= comment.username %>
                                </strong>
                                <img class="avatar" src="<%= comment.userheadimgurl %>">
                              </div>
                              <div class="weui-comment-msg">
                                <%- comment.body %>
                              </div>
                              <div class="comments-other">
                                <span class="time"><%= locals.moment(comment.created_at,'YYYYMMDD').fromNow() %></span>
                                <span class="comments reply-btn" data-id="<%= comment.userid %>">回复</span>
                              </div>
                          </li>
                        <% }) %>
                    <% } %>
                    <% if (article.comments.length <= 0) { %>
                        <p class="no-comments">没有评论，快评论一个吧 ~ </p>
                    <% } %>
                  </ul>
            </div>
          </div>

          <!-- 收藏、点赞、评论 -->
          <div class="action-other">
            <ul>
              <li class="collect-btn">
                <i class="iconfont">&#xe8e9;</i>
                <p>收藏</p>
              </li>
              <li class="meta-btn">
                <i class="iconfont">&#xe8e5;</i>
                <p>点赞</p>
              </li>
              <li class="comments-btn">
                <i class="iconfont">&#xe957;</i>
                <p>评论</p>
              </li>
            </ul>
          </div>
        </div>
    </div>
<script type="text/javascript" src="/js/detail.js"></script>